import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { orderPicRrdListData } from '/@/api/m8/order/order';

const { t } = useI18n('order.pic');

const modalProps = {
  title: t('图纸选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 90,
  showResetButton: false,
  schemas: [
    {
      label: t('图名'),
      field: 'picname',
      component: 'Input',
    },
    {
      label: t('订单号'),
      field: 'orderCode',
      component: 'Input',
    },
    // {
    //   label: t(''),
    //   field: 'poOver',
    //   component: 'CheckboxGroup',
    //   componentProps: {
    //     options: [{ label: '采购完成', value: '1' }],
    //   },
    // },
    {
      label: t('下图日期'),
      field: 'order.xtdate',
      component: 'RangePicker',
    },
    {
      label: t('图号'),
      field: 'picno',
      component: 'Input',
    },
    {
      label: t('客户'),
      field: 'cusCode',
      component: 'Input',
      show: false,
    },
  ],
  fieldMapToTime: [['order.xtdate', ['order.xtdate_gte', 'order.xtdate_lte']]],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('图号'),
    dataIndex: 'picno',
    key: 'a.picno',
    sorter: true,
    width: 130,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('图名'),
    dataIndex: 'picname',
    key: 'a.picname',
    sorter: true,
    width: 230,
    align: 'left',
  },
  {
    title: t('规格'),
    dataIndex: 'cinvstd',
    key: 'a.cinvstd',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('订单编号'),
    dataIndex: 'orderCode',
    key: 'a.order_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('下图日期'),
    dataIndex: 'order.xtdate',
    key: 'm8Order.xtdate',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('单价'),
    dataIndex: 'fprice',
    key: 'a.fprice',
    sorter: true,
    width: 100,
    align: 'right',
    ifShow: false,
  },
  {
    title: t('剩余数量'),
    dataIndex: 'iqty',
    key: 'a.iqty',
    sorter: true,
    width: 100,
    align: 'right',
  },
];

const tableProps: BasicTableProps = {
  api: orderPicRrdListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'picno',
  itemName: 'picname',
};
